
function runGeocode() {
    var address = $("#structure").val() + " " + $("#street").val() + " " + $("#city").val() + " " + $("#zip").val() + " " + $("#country").val();
    alert('address: 123 ' + address);
    showAddress(address, "lat", "lng");
}

function showAddress(address, tLat, tLng) {
    try {        
        geocoder.geocode({'address': address}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                map.setZoom(15);
                var marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location
                });
                $("#" + tLat).val(results[0].geometry.location.lat());
                $("#" + tLng).val(results[0].geometry.location.lng());
            } 
            else {
                alert("Geocode was not successful for the following reason: " + status);
            }
        });
    } catch (e) {
        alert(e);
    }
}